package com.example.qihuibao.module.login

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.example.qihuibao.network.RetrofitModel

/**
 *@author: cww
 *@desc:
 *@date: 4/22/23 11:18 AM
 */
class LoginRepository {

    inline fun <reified T> login() : LiveData<T> {
        val data = MutableLiveData<T>()

        val jsonObj = org.json.JSONObject()
//        jsonObj.put("timestamp", System.currentTimeMillis())
        RetrofitModel.postJson("/source/auth/eg-access/access", jsonObj, object : RetrofitModel.Result<T> {
            override fun onSucced(result: T) {
                data.value = result
            }

            override fun onFailed(errMsg: String) {
                data.value = null
            }
        })

        return data
    }

}